import java.awt.*; 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.ArrayList;

import javax.swing.*; 
 
public class mainclassi extends JPanel implements ActionListener {

	/**
	 * @param args
	 */
	
    protected JButton b1,b2,b3,choose;
	protected JLabel desc1, desc2, desc3;
    protected JLabel mini1, mini2, mini3;
    protected JLabel kuva;
    protected JLabel story, textLabel;
    protected ImageIcon kuvaIcon;
    protected int choice;
    protected static player ukko;
    
    public mainclassi() {
    	 

    	kuvaIcon = new ImageIcon("birth.png");
    	//<HTML>This is a line<BR>This is another line</HTML>
    	//"You are born to this world known as Flash. Where were you born? _"
        textLabel = new JLabel("<HTML><font size=+1>You are born to this world known as <b>Flash</b>. Where were you born? _</font></HTML>",SwingConstants.CENTER);
        desc1 = new JLabel("<HTML>The Woods. The home to the brave, strong and wild woods people.<BR> You are stronger, with <b>+20% damage.</b></HTML>");
        desc2 = new JLabel("<HTML>Riverlands. A busy trading area around vast rivers where cunning is key.<BR>You are a fast learner, with <b>+15% experience.</b></HTML>");
        desc3 = new JLabel("<HTML>King's Castle. A well protected community working for the King,<BR> with notable perks and safety. You are well built, with <b>+33% HP.</b></HTML>");
        mini1 = new JLabel("<HTML>+20% damage</html>");
        mini2 = new JLabel("<HTML>+15% experience</html>");
        mini3 = new JLabel("<HTML>+33% HP</html>");
        kuva = new JLabel(kuvaIcon);
        textLabel.setBounds(100,350,600,50);
        Font f = textLabel.getFont();
        textLabel.setFont(f.deriveFont(f.getStyle() & ~Font.BOLD));
        desc1.setBounds(200,300,600,50);
        desc2.setBounds(200,300,600,50);
        desc3.setBounds(200,300,600,50);
        desc1.setFont(f.deriveFont(f.getStyle() & ~Font.BOLD));
        desc2.setFont(f.deriveFont(f.getStyle() & ~Font.BOLD));
        desc3.setFont(f.deriveFont(f.getStyle() & ~Font.BOLD));
        mini1.setBounds(155,460,600,50);
        mini2.setBounds(360,460,600,50);
        mini3.setBounds(590,460,600,50);
        mini1.setVisible(false);
        mini2.setVisible(false);
        mini3.setVisible(false);
        kuva.setBounds(200,30,400,250);
        kuva.setVisible(true);
        story = new JLabel("Story part goes here");
        story.setBounds(200,300,600,50);
        
        b1 = new JButton("The Woods");
        b1.setBounds(120, 420, 150, 50);


        b2 = new JButton("Riverlands");
        b2.setBounds(330, 420, 150, 50);
        b3 = new JButton("King's Castle");
        b3.setBounds(540, 420, 150, 50);
        choose = new JButton("Choose");
        choose.setBounds(330, 480, 150, 50);
        choose.setVisible(false);
        desc1.setVisible(false);
        desc2.setVisible(false);
        desc3.setVisible(false);
        story.setVisible(false);
        b1.setActionCommand("1");
        b2.setActionCommand("2");
        b3.setActionCommand("3");
        choose.setActionCommand("c");
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        choose.addActionListener(this);

        add(textLabel); 
        add(desc1);
        add(desc2);
        add(desc3);
        add(mini1);
        add(mini2);
        add(mini3);
        add(choose);
        add(b1);
        add(b2);
        add(b3);  
        add(kuva);
        add(story);


     }
    
    public void actionPerformed(ActionEvent e) {

        if ("1".equals(e.getActionCommand()) && choice < 4) {
            choose.setVisible(true);
            choose.setBounds(120, 510, 150, 50);
            desc1.setVisible(true);
            desc2.setVisible(false);
            desc3.setVisible(false);
            mini1.setVisible(true);
            mini2.setVisible(false);
            mini3.setVisible(false);
            choice = 1;
        } else if ("2".equals(e.getActionCommand()) && choice < 4) {
        	choose.setVisible(true);
        	choose.setBounds(330, 510, 150, 50);
            desc2.setVisible(true);
            desc1.setVisible(false);
            desc3.setVisible(false);
            mini2.setVisible(true);
            mini1.setVisible(false);
            mini3.setVisible(false);
            choice = 2;
        } else if ("3".equals(e.getActionCommand()) && choice < 4) {
        	choose.setVisible(true);
        	choose.setBounds(540, 510, 150, 50);
        	desc3.setVisible(true);
            desc1.setVisible(false);
            desc2.setVisible(false);
            mini3.setVisible(true);
            mini2.setVisible(false);
            mini1.setVisible(false);
            choice = 3;
        }
        if ("c".equals(e.getActionCommand())) {
        	choose.setEnabled(false);
        	//System.out.println("Checking choice:");
        	if (choice == 1) {
        		b2.setVisible(false);
        		b3.setVisible(false);
        		ukko.setDamageModifier(120);
        		textLabel.setText("<html><font size=+2>Flash of the Woods</font></html>");
        		story.setText("<html>You were born in the Woods. Your father was a hunter while your mother kept a hut. <br>Your story is about to unfold now.</html>");
        		b1.setText("Play");
        		story.setVisible(true);
        		desc1.setVisible(false);
        		choice = 4;
        	} else if (choice == 2) {
        		b1.setVisible(false);
        		b3.setVisible(false);
        		ukko.setExperienceModifier(115);
        		textLabel.setText("<html><font size=+2>Flash of the Riverlands</font></html>");
        		story.setText("<html>You were born in the Riverlands. Your father had a boat, your mother sold fish. <br>Your story is about to unfold now.</html>");
        		b2.setText("Play");
        		story.setVisible(true);
        		desc2.setVisible(false);
        		choice = 4;
        	}
        	else if (choice == 3) {
        		b1.setVisible(false);
        		b2.setVisible(false);
        		ukko.setHpModifier(133);
        		textLabel.setText("<html><font size=+2>Flash of the King's Castle</font></html>");
        		story.setText("<html>You were born in the King's Castle. Your father was a soldier and your mother a servant. <br>Your story is about to unfold now.</html>");
        		b3.setText("Play");
        		story.setVisible(true);
        		desc3.setVisible(false);
        		choice = 4;
        	}
        	//System.out.println(choice);
        }
    } 
    
}